package com.buttonpay.home;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.DatePicker;

import com.buttonpay.R;

public class SummryDialog extends Dialog implements android.view.View.OnClickListener
{
	Button btnOk;
	DatePicker dp_startdate,dp_enddate;
	int startdate,startmonth,startyear,enddate,endmonth,endyear;
	public String startdt,enddt;
	 
	Context ctx;
	public SummryDialog(Context context) 
	{
		super(context);
		this.ctx=context;
		
		requestWindowFeature(Window.FEATURE_NO_TITLE) ;
		setContentView(R.layout.date_layout);
		
		btnOk=(Button)findViewById(R.id.button1);
		dp_startdate=(DatePicker)findViewById(R.id.datePickerFromDate);
		dp_enddate=(DatePicker)findViewById(R.id.datePickerToDate); 
		btnOk.setOnClickListener(this);
	}

	public void onClick(View v)
	{
		if(v==btnOk)
		{
			
/*			startdate=dp_startdate.getDayOfMonth();
			startmonth=dp_startdate.getMonth();
			startyear=dp_startdate.getYear()-1900;
			
			enddate=dp_enddate.getDayOfMonth();
			endmonth=dp_enddate.getMonth();
			endyear=dp_enddate.getYear()-1900;*/
			
			Date sDate=new Date(dp_startdate.getYear()-1900,dp_startdate.getMonth(),dp_startdate.getDayOfMonth());
			Date eDate=new Date(dp_enddate.getYear()-1900,dp_enddate.getMonth(),dp_enddate.getDayOfMonth());
			
			System.out.println("Sdate:"+sDate.toString());
			System.out.println("EDate:"+eDate.toString());
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
			String startDate=formatter.format(sDate);
			String endDate=formatter.format(eDate);
			  
		     Bundle bundle=new Bundle();
		     
		     bundle.putString("startDate", startDate);
		     bundle.putString("endDate", endDate);
		     dismiss();
		    ((Activity)ctx).startActivityForResult(new Intent((Activity)ctx,BusinessSummaryActivity.class).putExtras(bundle), 11);
			/*if(enddate>currentDay || endmonth>currentMonth || endyear>currentYear)
			{
				Toast.makeText(ctx, "Please Select valid Date", Toast.LENGTH_LONG).show();
			}*/ 
			
		}
		
	}
 
}
